package com.jfire.baseutil.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class StreamTool
{
    /**
     * 从输出流读取数据直到流的末尾
     * 
     * @param inputStream
     * @param outputStream
     * @param cacheSize
     * @throws IOException
     */
    public static void transfer(InputStream inputStream, OutputStream outputStream, int cacheSize) throws IOException
    {
        byte[] cache = new byte[cacheSize];
        int read = 0;
        while ((read = inputStream.read(cache)) != -1)
        {
            outputStream.write(cache, 0, read);
        }
    }
}
